package Classes.GameDatas
{
	import Classes.GameUtils.GU_Sound;
	import Classes.GameUtils.GU_dealPower;
	import Classes.GameViews.GV_Map;
	import Classes.GameViews.ViewDisplayers.MapTargets.MapMoveTargets.MMT_Character;
	import Classes.GameViews.ViewPanels.VP_OpenWinView;
	import Classes.GameViews.ViewPanels.VP_QQTQView;
	import Classes.GameViews.ViewPanels.VP_TextWinPanel;
	import Classes.GameViews.ViewPanels.VP_errorPanel;
	import Classes.Managers.M_Communication;
	import Classes.Managers.M_ConfigData;
	import Classes.staticinfo.Language;
	
	import UIComponents.IFriendInfo;
	
	import com.greensock.TweenLite;
	
	import flash.display.DisplayObject;
	import flash.display.GradientType;
	import flash.display.Sprite;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.system.ApplicationDomain;
	
	/**
	 * 好友列表中 好友的信息类 
	 * @author Administrator
	 */	
	public class GD_SingleFriend extends GameData implements IFriendInfo
	{
		private var _friendID:Number;
		
		private var _friendName:String;
		
		private var _friendViewID:String;
		
		private var _friendJob:String;
		
		private var _visitSign:int;
		
		private var _friendLV:int;
		
		private var _isHired:int;
		
		private var _isMySelft:Boolean;
		
		private var _friendHiredMoney:Number;
		
		private var _playerSex:String;
		
		private var _friendWeaponId:Number;
		
		private var _friendQqVip:int;
		
		private var _qqVipIcon:DisplayObject;
		
		private var _friendAct:Number;
		
		public function GD_SingleFriend()
		{
		}
		
		/**
		 * 好友ID 
		 */
		public function get friendID():Number
		{
			return _friendID;
		}
		
		/**
		 * @private
		 */
		public function set friendID(value:Number):void
		{
			_friendID = value;
		}
		
		/**
		 * 好友名字 
		 */
		public function get friendName():String
		{
			return _friendName;
		}
		
		/**
		 * @private
		 */
		public function set friendName(value:String):void
		{
			_friendName = value;
		}
		
		/**
		 * 好友头像ID 
		 */
		public function get friendViewImg():String
		{
			return _friendViewID;
		}
		
		/**
		 * @private
		 */
		public function set friendViewID(value:String):void
		{
			_friendViewID = value;
		}
		
		/**
		 * 好友职业 
		 */
		public function get friendJob():String
		{
			return _friendJob;
		}
		
		/**
		 * @private
		 */
		public function set friendJob(value:String):void
		{
			_friendJob = value;
		}
		
		/**
		 * 获取擅长领域的图片 
		 * @return 
		 */		
		public function get friendJobIcon():DisplayObject
		{
			var dis:DisplayObject=null;
			if(int(friendJob)>0)dis=new (ApplicationDomain.currentDomain.getDefinition("job"+friendJob) as Class);
			return dis;
		}
		
		/**
		 * 拜访标记（0尚未拜访，1已拜访）
		 */
		public function get visitSign():int
		{
			return _visitSign;
		}
		
		/**
		 * @private
		 */
		public function set visitSign(value:int):void
		{
			_visitSign = value;
		}
		
		/**
		 * 好友等级
		 */
		public function get friendLV():int
		{
			return _friendLV;
		}
		
		/**
		 * @private
		 */
		public function set friendLV(value:int):void
		{
			_friendLV = value;
		}
		
		/**
		 * 雇佣标记（0 可以雇佣 ，1不可以雇佣） 
		 */
		public function get isHired():int
		{
			return _isHired;
		}
		
		/**
		 * @private
		 */
		public function set isHired(value:int):void
		{
			_isHired = value;
		}
		
		/**
		 * 是否是玩家自己 
		 */
		public function get isMySelft():Boolean
		{
			return _isMySelft;
		}
		
		/**
		 * @private
		 */
		public function set isMySelft(value:Boolean):void
		{
			_isMySelft = value;
		}
		
		public function get friendAct():Number
		{
			return this._friendAct;
		}
		
		public function set friendAct(v:Number):void
		{
			this._friendAct	=	v;
		}
		
		
		
		public function hireFriendFun():void
		{
			//如果玩家在好友家则不能雇佣好友
			if(GD_Player.instance.character.characterState!=0)
			{
				VP_errorPanel.instance.setErrorMessage(Language.hirdErrorTips);
				VP_errorPanel.instance.enterFrame();
				return ;
			}
			
			if(!GU_dealPower.instance.isHavePower(10000210))
			{
				VP_errorPanel.instance.noPowerMsg();
				return;
			}
			if(this.isHired==1)
			{
				VP_errorPanel.instance.setErrorMessage(Language.isHired);
				VP_errorPanel.instance.enterFrame();
				GU_Sound.instance.playCommSound("System_Prompt");
			}else{
				if(GD_Player.instance.money<this.friendHiredMoney)
				{
					VP_errorPanel.instance.setErrorMessage(Language.yinbiBuzu);
					VP_errorPanel.instance.enterFrame();
				}
				else if(GD_AllFriends.instance.getHiredNum()>=M_ConfigData.instance.hiredFriendNum)
				{
					VP_errorPanel.instance.setErrorMessage(Language.hiredFriendMax);
					VP_errorPanel.instance.enterFrame();
					GU_Sound.instance.playCommSound("System_Prompt");
				}else{
					var hireStr:String=Language.hiredFriendContext.replace("$hiremoeny",this.friendHiredMoney.toString());
					VP_TextWinPanel.instance.openTextWindon(Language.hiredFriendTitle,hireStr,callFired);
				}
			}
		}
		
		private function callFired():void
		{
			//做新手指导的判断
			if(this.friendID==GD_AllFriends.instance.systemFriendId)
			{
				GU_dealPower.instance.removeArrowForFriend();
			}
			M_Communication.instance.send(127002,{friendID:this.friendID});
		}
		
		public function visiableFriendFun():void
		{  
			if(GD_AllFriends.instance.currentVisableFriendId==this.friendID)return;
			
			if(!GU_dealPower.instance.isHavePower(10000209))
			{
				VP_errorPanel.instance.noPowerMsg();
				return;
			}
			
			GD_AllFriends.instance.currentVisableFriendId=this.friendID;
			GD_AllFriends.instance.currentVisableFriend=this;
			VP_OpenWinView.instance.openGotoFriendPanel();		//小加载条开始
			GD_HavenWall.setIsHome(false);						//入侵部分，好友不做返应
			M_Communication.instance.send(11002,{friendID:this.friendID});
		}
		
		/**
		 * 雇佣金额 
		 */
		public function get friendHiredMoney():Number
		{
			return _friendHiredMoney;
		}
		
		/**
		 * @private
		 */
		public function set friendHiredMoney(value:Number):void
		{
			_friendHiredMoney = value;
		}
		
		/**
		 * 玩家性别（1男，0女）
		 */
		public function get playerSex():String
		{
			return _playerSex;
		}
		
		/**
		 * @private
		 */
		public function set playerSex(value:String):void
		{
			_playerSex = value;
		}
		
		/**
		 * 在家定位选中改玩家 
		 */		
		public function goMyHome():void
		{
			if(GD_Player.instance.character.characterState==2 && this.friendID!=GD_Player.instance.playerID )return;
			var mmt:MMT_Character=GV_Map.instance.getPlayerControlTagetById(this.friendID);
			if(null!=mmt)
			{
				var toy:Number=-(mmt.y+GV_Map.instance.layerMapTargets.y)+GV_Map.instance.stage.stageWidth*0.3;
				var tox:Number=-(mmt.x+GV_Map.instance.layerMapTargets.x)+GV_Map.instance.stage.stageHeight*0.6;
				
				var maxTox:Number	=	GV_Map.instance.width/2;
				var maxToy:Number	=	GV_Map.instance.height-GV_Map.instance.stage.stageHeight;
				toy	= toy>0?0:toy;
				toy = toy<-maxToy?-maxToy:toy;
				
				tox = tox>maxTox?maxTox:tox;
				tox = tox<-(maxTox-GV_Map.instance.stage.stageWidth)?-(maxTox-GV_Map.instance.stage.stageWidth):tox;
				
				TweenLite.to(GV_Map.instance,2,{y:toy,x:tox});
				if(GV_Map.instance.controlTarget	!=	mmt)
				{
					(GV_Map.instance.controlTarget as MMT_Character).controlJianTouVisable(false);
					GV_Map.instance.controlTarget	=	mmt;
					mmt.controlJianTouVisable(true);
				}
				if(this.friendID==GD_AllFriends.instance.systemFriendId)
				{
					GU_dealPower.instance.isInFriendHome=false;
					GU_dealPower.instance.isSelectFriend=true;
					GU_dealPower.instance.removeArrowForFriend();
				}
			}
		}
		
		/**
		 * 好友携带的基础武器 
		 */
		public function get friendWeaponId():Number
		{
			return _friendWeaponId;
		}
		
		public function set friendWeaponId(value:Number):void
		{
			_friendWeaponId = value;
		}
		
		/**
		 * 查看QQ黄钻特权 
		 */		
		public function kanQQTeQuan():void
		{
			//打开黄钻特权页面
			GD_QQhz.instance.seeVipTq();
		}
		
		public function get friendQqVip():int
		{
			return _friendQqVip;
		}
		
		/**
		 * 好友黄钻等级 (0 表示不是黄钻 1 表示一级黄钻  9 表示 年黄钻一级  10 表示年 黄钻二级) 
		 * @return 
		 */	
		public function set friendQqVip(value:int):void
		{
			_friendQqVip = value;
			if(value>0)
				this.qqVipIcon=new (ApplicationDomain.currentDomain.getDefinition("v"+value) as Class);
		}
		
		/**
		 * 好友Vip图形 
		 * @return 
		 */		
		public function get qqVipIcon():DisplayObject
		{
			return _qqVipIcon;
		}
		
		public function set qqVipIcon(value:DisplayObject):void
		{
			_qqVipIcon = value;
		}
		
		
	}
}